<template>
	<layout :loading="loading" curPage="menu" title="菜单列表">

		<block slot="title">
			<authNav href="/pages/menu/menuEdit" url="/admin/menu/info" class="layui-btn layui-btn-sm">
				<i class="layui-icon layui-icon-add-1"></i>
				添加
			</authNav>
		</block>

		<div class="layui-form layui-border-box layui-table-view">

			<tableList :list="list" :canSelect="false">

				<block slot="head">
					<th>名称</th>
					<th>ID</th>
					<th>排序</th>
					<th>菜单类型</th>
					<th>URL</th>
					<th class="autoWidth">路径</th>
					<th>操作</th>
				</block>

				<block slot="body">
					
					<block v-for="( x , index) in list" :key="index" v-if="x.type == 1">
						
						<tr>
							<td class="mainText">{{x.name}}</td>
							<td><copy :text="x.id">{{x.id}}</copy></td>
							<td>{{x.orderNum}}</td>
							<td>{{x.typeName}}</td>
							<td>
								<moreTip style="width: 200px;" :tips="x.url" >{{x.url}}</moreTip>
							</td>
							<td>
								
							</td>
							<td>
								<authNav :href="'/pages/menu/menuEdit?id=' + x.id" url="/admin/menu/info" class="layui-btn layui-btn-xs">
									编辑
								</authNav>
								<authBtn :url="'/admin/menu/delete?id='+x.id" confirm="delete" :callBack="true" @success="kit.getList(action)" class="layui-btn layui-btn-xs">
									删除
								</authBtn>
							</td>
						</tr>
						
						<block v-for="( s , sIndex) in list" :key="s.id" v-if="s.parentId == x.id && s.type == 2">
							
							<tr>
								<td> 
									<span class="layui-icon layui-icon-next" style="font-size: 12px;margin-left: 10px;margin-right: 5px;"></span> 
									<b style="color: #000;">{{s.name}}</b>
								</td>
								<td><copy :text="s.id">{{s.id}}</copy></td>
								<td>{{s.orderNum}}</td>
								<td>
									{{s.typeName}}
								</td>
								<td><moreTip style="width: 200px;" :tips="s.url" >{{s.url}}</moreTip></td>
								<td>
									{{s.pages}}
								</td>
								<td>
									<authNav :href="'/pages/menu/menuEdit?id=' + s.id" url="/admin/menu/info" class="layui-btn layui-btn-xs">
										编辑
									</authNav>
									<authBtn :url="'/admin/menu/delete?id='+s.id" confirm="delete" class="layui-btn layui-btn-xs">
										删除
									</authBtn>
								</td>
							</tr>
							
							<block v-for="( t , sIndex) in list" :key="t.id" v-if="t.parentId == s.id && t.type == 3">
								
								<tr>
									<td><span style="padding-left: 25px;">{{t.name}}</span></td>
									<td><copy :text="t.id">{{t.id}}</copy></td>
									<td>{{t.orderNum}}</td>
									<td>{{t.typeName}}</td>
									<td><moreTip style="width: 200px;" :tips="t.url" >{{t.url}}</moreTip></td>
									<td></td>
									<td>
										<authNav :href="'/pages/menu/menuEdit?id=' + t.id" url="/admin/menu/info" class="layui-btn layui-btn-xs">
											编辑
										</authNav>
										<authBtn :url="'/admin/menu/delete?id='+t.id" confirm="delete" class="layui-btn layui-btn-xs">
											删除
										</authBtn>
									</td>
								</tr>
								
							</block>
							
						</block>
						
					</block>

				</block>

			</tableList>
			
			<emptyTips :loading="true" :list="list"></emptyTips>

		</div>


	</layout>
</template>

<script>
	export default {
		data() {
			return {
				loading: true ,
				action: "/admin/menu/list",
				list: []
			}
		},

		onShow() {
			this.kit.getList(this.action);
		},

		methods: {
			
		}
	}
</script>
